package com.cssl.controller;

import com.cssl.domain.DtsAdmin;
import com.cssl.domain.dto.DtsAdminDto;

import com.cssl.domain.vo.LoginVO;

import com.cssl.openFeign.AdminFeignClient;

import com.cssl.util.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin")
@Api(value = "管理员接口",tags = "管理员相关操作")
public class AdminController {
    @Autowired
    private AdminFeignClient client;

    /**
     * 登录
     *
     * @param loginVO
     * @return
     */
    @PostMapping("/login")
    Result login(@RequestBody LoginVO loginVO) {
        System.out.println("登录:" + loginVO);

        return client.login(loginVO);
    }

    /**
     * 图形验证码
     *
     * @return
     */
    @GetMapping("/getCaptcha")
    Result getImageCode() {
        return client.getImageCode();
    }

    /**
     * 获得用户信息列表
     * @param map
     * map包含参数:
     * page:页数
     * limit:每页的数据量
     * userName:搜索用户姓名
     * userMobile:搜索用户手机号
     * isLock:用户状态
     * @return
     */
//    @PostMapping("/getUserList")
//    public Result getUserList(@RequestBody Map map){
//        Page userList = dtsUserService.getUserList(map);
//        if (userList!=null){
//            return Result.fail(InfoCode.QUERY_EMPTY, InfoCode.MESSAGE_QUERY_EMPTY, System.currentTimeMillis());
//        }
//        return Result.result(InfoCode.OK,InfoCode.MESSAGE_OK,userList,System.currentTimeMillis());
//    }

    /**
     * 获取角色
     *
     * @param map id
     * @return
     */
    @PostMapping("/getRole")
    public Result getRolesById(@RequestBody Map map) {
        return client.getRolesById(map);
    }

    @PostMapping("/listAdmin")
    public Result listAdmin(@RequestBody DtsAdminDto dto) {
        return client.listAdmin(dto);

    }

    @PostMapping("/createAdmin")
    public Result createAdmin(@RequestBody DtsAdmin admin) {
        return client.createAdmin(admin);
    }

    @PostMapping("/updateAdmin")
    public Result updateAdmin(@RequestBody DtsAdmin admin) {
        return client.updateAdmin(admin);
    }
    @PostMapping("/deleteAdmin")
    public Result deleteAdmin(@RequestBody DtsAdmin admin){
        return client.deleteAdmin(admin);
    }
}

